package com.example.demo.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.demo.dao.TagMapper;
import com.example.demo.model.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 功能描述：
 *
 * @Author: Zhanghf
 * @Date: 2021/6/22 17:52
 */
@Service
public class TagService {
    @Autowired
    private TagMapper tagMapper;
    public void addtag(Integer chapterid, Integer userid, Integer bookid)
    {
        tagMapper.insert(new Tag(userid,bookid,chapterid,new Date()));
    }
    public String deletetag(Integer chapterid, Integer userid, Integer bookid)
    {
        tagMapper.delete(new QueryWrapper<Tag>().eq("bookid",bookid)
            .eq("chapterid",chapterid)
            .eq("userid",userid));
        return "forward:personhistory";
    }
    public  List<Tag> getTag(Integer userid)
    {
        List<Tag> tags = tagMapper.selectList(new QueryWrapper<Tag>().eq("userid", userid));
        return tags;
    }


}

